package com.atguigu.springcloud.config;

import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author timo 2021/3/12
 */
@Configuration
@MapperScan({"com.atguigu.**.mapper.**"})
@EnableConfigurationProperties({MybatisPlusProperties.class})
@PropertySource("classpath:/defal-mybatis.yml")
@EnableTransactionManagement
public class MybatisPlusConfiguration {
    /**
     * mybatis plus分页插件配置
     * @return
     */
    @Bean
    @ConditionalOnClass(value = {PaginationInterceptor.class})
    public PaginationInterceptor paginationInterceptor(){
        return new PaginationInterceptor();
    }
}
